package com.example.fang.demodruid;

import com.example.fang.demodruid.entity.test.EnvConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ImportResource;
import org.springframework.core.env.ConfigurableEnvironment;

@SpringBootApplication
@ImportResource(locations = { "classpath:druid-bean.xml" })

public class DemoDruidApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext run= SpringApplication.run(DemoDruidApplication.class, args);
        ConfigurableEnvironment environment=run.getEnvironment();
        String serverType=environment.getProperty("secretType");
        //非spring环境下获取系统变量
        EnvConfig envConfig=new EnvConfig();
        envConfig.setSecretType(serverType);
        System.out.println("获取到的serverType"+serverType+"服务启动成功");
    }

}
